{% extends "./inc/base.html" %}
{% block content %}
                <section class="vbox">
                    <header class="header bg-light dk">
                        <p>{{controller.meta_title}}</p>
                    </header>
                    <section class="scrollable wrapper">

                        <section class="panel panel-default">
                            <header class="panel-heading">
                                发布列表
                            </header>
                            <div class="row wrapper">

                                <div class="col-sm-9 m-b-xs">
                                    <div class="btn-group">

                                        <a class="btn btn-sm btn-info {%if status == null %}active{%endif%}" href="/admin/gongxufabu/list">
                                           全部发布
                                        </a>
                                        <a class="btn btn-sm btn-info {%if status == 0 %}active{%endif%}" href="/admin/gongxufabu/list/?status=0">
                                           未审核
                                        </a>
                                        <a class="btn btn-sm btn-info {%if status != 0 %}active{%endif%}" href="/admin/gongxufabu/list/?status!=0">
                                           已审核
                                        </a>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="input-group pull-right search-form">
                                        <input type="text" class="input-sm form-control" name="q" placeholder="订单号|会员ID|收货人|收货人电话"
                                               value="{{controller.get('q')}}">
                                        <span class="input-group-btn">
                        <button class="btn btn-sm btn-default" type="button" id="search" url="/admin/gongxufabu/list/{%if status %}?status=2{% endif %}">搜索</button>
                      </span>
                                    </div>
                                </div>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-hover b-t b-light">
                                    <thead>
                                    <tr>
                                        <th style="width:20px;"><label class="checkbox m-n i-checks"><input type="checkbox"><i></i></label></th>
                                        <th>发布人</th>
                                        <th>类型</th>
                                        <th>品类</th>
                                        <th>地区</th>
                                        <th>数量</th>
                                        <th>价格</th>
                                        <th>状态</th>
                                        <th>模块</th>
                                        <th>派单</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for item in list %}
                                    <tr >
                                        <td><label class="checkbox m-n i-checks"><input class="ids" type="checkbox" name="ids" value="{{item.id}}"><i></i></label></td>
                                        <td><a href="/admin/user/showuser/?id={{item.faburen}}" class="text-info" data-toggle="ajaxModal">{{item.faburen|get_realname}}</a></td>
                                        <td>{%if item.xinxileixing ==0 %}<span> 供应</span>{%elif item.xinxileixing ==1%}<span> 采购</span>{%elif item.xinxileixing ==2%}<span> 委托加工</span>{%elif item.xinxileixing ==3%}<span> 承接加工</span>{%endif%}</td>
                                        <td>{{item.shangpingleibie}}</td>
                                        <td>{{item.diqu}}</td>
                                        <td>{{item.shangpingshuliang}}</td>
                                        <td>￥{{item.jiage}}</td>
                                        <td class="text-danger">
                                            {%if item.status == 0%}<span class="text-muted">待审核</span>
                                            {%elif item.status == 1%}<span class="text-success">已审核</span>
                                            {%elif item.status == 2%}<span class="text-success">已退回</span>
                                            {%elif item.status == 3%}<span class="text-success">已派单</span>
                                            {%elif item.status == 4%}<span class="text-success">已接单</span>
                                            {%elif item.status == 5%}<span class="text-primary">已上架</span>
                                            {%else%}<del>已下架</del>{%endif%}</td>
                                        <td>{%if item.mokuaibiaoshi ==0 %}<span> 社区回收</span>{%elif item.mokuaibiaoshi ==1%}<span> 供销市场</span>{%elif item.mokuaibiaoshi ==2%}<span> 商品交易</span>{%endif%}</td>
                                        <td>{{item.appmobile}}</td>
                                        <td><div class="btn-group">
		                  <button data-toggle="dropdown" class="btn btn-default btn-xs dropdown-toggle"><i class="fa fa-cog"></i> 处理 <span class="caret"></span></button>
		                  <ul class="dropdown-menu dropdown-menu-right">
                              <li><a href="/admin/gongxufabu/see/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-eye"></i> 查看</a></li>
                              {%if item.status == 0 or item.status == 1 %}
                              <li><a href="/admin/gongxufabu/shifang/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-check-square-o"></i> 释放</a></li>
                              {%endif%}
                              {%if item.status == 0 or item.status == 1 or item.status == 3%}
                              <li><a href="/admin/gongxufabu/audit/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-check-square-o"></i> 审核</a></li>
                              {%endif%}
                              {%if item.status != 4%}
                              <li><a href="/admin/gongxufabu/void/?id={{item.id}}" data-toggle="ajaxModal"><i class="fa fa-trash-o"></i> 下架</a></li>
                              {%endif%}


		                  </ul>
		                </div></td>
                                    </tr>
                                    {% else %}
                                    <tr><td colspan="11"><div class="alert alert-warning alert-block">
                                        <button data-dismiss="alert" class="close" type="button">×</button>
                                        <p>暂无数据</p>
                                    </div></td></tr>

                                    {% endfor %}


                                    </tbody>
                                </table>
                            </div>
                            <footer class="panel-footer">
                                <div class="row">


                                    <div class="col-sm-12 text-right text-center-xs">
                                        {{pagerData | safe}}
                                    </div>
                                </div>
                            </footer>
                        </section>
                    </section>
                </section>

{% endblock %}
{% block script%}
<script src="/static/admin/js/parsley/parsley.min.js"></script>
<script src="/static/admin/js/parsley/parsley.extend.js"></script>
<script>
    $(function () {
      //搜索功能
      $("#search").click(function(){
        var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
          url += '&' + query;
        }else{
          url += '?' + query;
        }
        window.location.href = url;
      });

      //回车自动提交
      $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
          $("#search").click();
        }
      });

    })
</script>
{% endblock%}
